<?php defined("MAIN_DIR") or die("No direct access");

require_once ADMIN.HEADFILE;
?>
<div align="left">
<h1>Список пользователей</h1><?php
$users_query = "select * from `admin` order by `admin_id`";

$limit = 10;
$users_res = mysql_query($users_query);
$count = mysql_num_rows($users_res);
$page = 1;
if (isset($_GET['page']))
	$page = $_GET['page'];
$max_page = ceil($count/$limit);
if ($max_page == 0)
	$max_page++;
if ($page > $max_page)
	$page = $max_page;
elseif ($page < 1)
	$page = 1;
$start_list = (ceil($page)-1)*$limit;
$users_query .= " limit $start_list,$limit";
$users_res = mysql_query($users_query);
$users_count = mysql_num_rows($users_res);
?>
<table cellpadding="5" cellspacing="0" class='light'>
	<tr id='header'>
		<td width="30px" style="border-bottom:1px gray solid">ID</td>
		<td width="200px" style="border-bottom:1px gray solid">Логин</td>
		<td width="100px" style="border-bottom:1px gray solid">Последний IP</td>
		<td width="150px" style="border-bottom:1px gray solid">Последнее время</td>
		<td width="180px" style="border-bottom:1px gray solid">Действия</td>
	</tr><?php
	while ($users_row = mysql_fetch_array($users_res))
	{
		?><tr>
			<td><?php echo $users_row['admin_id']?></td>
			<td><?php echo $users_row['login']?></td>
			<td><?php echo $users_row['last_ip']?></td>
			<td><?php echo date("d.m.Y H:i",$users_row['last_time']); ?></td>
			<td>
				<a href='/admin/site/users/edit/<?php echo $users_row['admin_id']; ?>'>Редактировать</a><?php
				if ($users_row['admin_id'] != 1)
					echo " | <a onclick='return confirm_del()' href='/admin/site/users/delete/$users_row[admin_id]'>Удалить</a>";
			?></td>
		</tr><?php
	}
?></table>
<br /><a href='/admin/site/users/add/'>Добавить</a>
<br /><?php require_once APP."pageskin.php"; ?>
</div>

<?php require_once ADMIN.FOOTERFILE; ?>